package com.zhangjianling.premp.entity.sys;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 字典信息表
 *
 * @author zhangjl
 */
@Entity
@Table(name = "sys_dict")
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Dictionary implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid.hex")
    @Column(name = "dict_Id", nullable = false, length = 32)
    private String dictId;
    private String name;
    private String code;
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
    @JoinColumn(name = "pid")
    @JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
    private Dictionary parentDict;
    private String status;
    private String remark;
    private boolean open;
    @OneToMany(targetEntity = Dictionary.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER, mappedBy = "parentDict")
    @JsonIgnore
    private List<Dictionary> dicts = new ArrayList<Dictionary>();


}
